package outoforder.leetcode;

import org.junit.Test;

/**
 * @author shhjiang_001
 * @create 2020-07-07 21:46
 */
// 打家劫舍
public class Solution198 {
    public int rob(int[] nums) {
        int len = nums.length;
        int[][] dp = new int[len+1][2];
        for (int i = 1; i <= len; i++) {
            dp[i][0] = Math.max(dp[i-1][0],dp[i-1][1]);
            dp[i][1] = dp[i-1][0]+ nums[i-1];
        }

        return Math.max(dp[len][0],dp[len][1]);
    }
    @Test
    public void test(){
        System.out.println(rob(new int[]{2, 7, 9, 3, 1}));
    }

}
